/**
 * Created by JetBrains PhpStorm.
 * User: September5th
 * Date: 3/11/12
 * Time: 2:28 PM
 * To change this template use File | Settings | File Templates.
 */
Ext.define('EM.view.event.TimelineContextMenu', {
    extend:'Gnt.plugin.TaskContextMenu',
    createMenuItems:function () {
        var orignalMenu = this.callParent();
        var targets0 = ['Delete task(s)', 'Edit left label', 'Add...'];
        var newMenu = [];
        orignalMenu.forEach(function (item) {
            if (targets0.indexOf(item.text) > -1) {
                if (item.text == 'Delete task(s)') {
                    item.text = 'Delete event(s)';
                }
                if (item.text == "Add...") {
                    var orignalSubMenu = item.menu.items;
                    var newSubMenu = [];
                    var targets1 = ['Task below', 'Sub-task'];
                    orignalSubMenu.forEach(function (item) {
                        if (targets1.indexOf(item.text) > -1) {
                            if (item.text == 'Task below') {
                                item.text = "Event";
                            } else {
                                item.text = "Sub-event";
                            }
                            newSubMenu = newSubMenu.concat(item);
                        }
                    });
                    item.menu.items = newSubMenu;
                }
                newMenu = newMenu.concat(item);
            }
        });

        return newMenu;
        return newMenu.concat({
            text:'My handler',

            handler:this.onMyHandler,
            scope:this
        })
    },

    onMyHandler:function () {
        // the task on which the right click have occured

    }
});